﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/Adminitrator.master" AutoEventWireup="true" CodeFile="ProductVote.aspx.cs" Inherits="admin_Report_ProductVote" %>


<%@ Register Src="~/admin/Report.ascx" TagName="LinkReport" TagPrefix="uc" %>
<%@ Import Namespace="BLL" %>
<%@ Import Namespace="DAL" %>
<%@ Import Namespace="System.Collections.Generic" %>
<script runat="server">
  ProductBLL data = new ProductBLL();
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="Content" Runat="Server">
  <uc:LinkReport ID="LinkReport1" runat="server" />
  <h1 class="title">Sản phẩm xem nhiều</h1>
  <div style="margin: 10px">
      <table cellpadding="3" cellspacing="0" style="width: 100%; border-collapse:collapse">
      <tr style="background: #999999; color: WHITE">
        <td>STT</td>
        <td>Tên sản phẩm</td>
        <td>Mã sản phẩm</td>
        <td>Giá</td>
        <td>Số lượng hiện tại</td>
        <td>Bình chọn</td>
        <td>Số lượt bình chọn</td>
      </tr>
      <%
        int cate = -1;
        if (Request.QueryString["cate"] != null)
          try { cate = Convert.ToInt32(Request.QueryString["cate"]); }
          catch { }

        List<Product> list = new List<Product>();
        if (Request.QueryString["cate"] != null)
          list = data.GetByVote(cate);
        else
          list = data.GetByVote();
        
        int i =1;
        foreach (var item in list)
        {
          int vote = item.Vote;
          if (vote < 1) vote = 0;
          else if (vote <= 5) vote = 5;
          else if (vote <= 10) vote = 10;
          else if (vote <= 15) vote = 15;
          else if (vote <= 20) vote = 20;
          else if (vote <= 25) vote = 25;
          else if (vote <= 30) vote = 30;
          else if (vote <= 35) vote = 35;
          else if (vote <= 40) vote = 40;
          else if (vote <= 45) vote = 45;
          else if (vote <= 50) vote = 50;
          %>
            <tr>
             <td><%=i.ToString() %></td>
              <td><%=item.Name %></td>
              <td><%=item.Id.ToString() %></td>
              <td><%=(item.Cost == null?"":String.Format("{0:0,0}",item.Cost)) %></td>
              <td><%=item.Quantity.ToString() %></td>
              <td><img src = "../../Images/polls-<%=vote %>.png" /></td>
              <td><%=item.TotalVote.ToString() %></td>
            </tr>
          <%
            i++;
        }
         %>
    </table>
  </div>
</asp:Content>


